package cqueue.posting;

import tcp.unicast.TCPServer;
import cqueue.ListenerEvent;

/**
 * This can be thought of as the "master" tcp post service. It maintains
 * a TCP connection with all of the nodes. It will marshal the event data
 * to skeletons on the "nodes".  
 * 
 * Note: Generics could be used instead of binding the type now for a more
 * flexible design.  Binding here makes life a lot easier since we only
 * need event listening.  Bubbling blows.
 * 
 * @author Kristopher L. Kalish, James Madison University
 * @version 1 - March 24, 2008 (initial design)
 * @version 2 - April 6, 2008 (rewrite)
 *
 */
public class TcpPostServiceStub implements PostService<ListenerEvent>
{
	private TCPServer server;
	
	public TcpPostServiceStub(int listenPort)
	{
		server = new TCPServer(listenPort);
		server.start();
	}
	
	public void postEvent(ListenerEvent event)
	{
		server.sendToAll(event);
	}
}
